﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.ComponentModel.DataAnnotations;
using WalkingTec.Mvvm.Core;
using WalkingTec.Mvvm.Core.Extensions;
using TyMES.Model.Record;
using TyMES.Model;

namespace TyMES.ViewModel.Record.InnerAndOutRingRecordVMs
{
    public partial class InnerAndOutRingRecordListVM : BasePagedListVM<InnerAndOutRingRecord_View, InnerAndOutRingRecordSearcher>
    {
        
        protected override IEnumerable<IGridColumn<InnerAndOutRingRecord_View>> InitGridHeader()
        {
            return new List<GridColumn<InnerAndOutRingRecord_View>>{
                
                this.MakeGridHeader(x => x.InnerAndOutRingRecord_InnerMFCode).SetTitle(@Localizer["Page.内圈厂家编码"].Value),
                this.MakeGridHeader(x => x.InnerAndOutRingRecord_InnerVSN).SetTitle(@Localizer["Page.内圈绑定VSN"].Value),
                this.MakeGridHeader(x => x.InnerAndOutRingRecord_OutMFcode).SetTitle(@Localizer["Page.外圈厂家编码"].Value),
                this.MakeGridHeader(x => x.InnerAndOutRingRecord_OutVSN).SetTitle(@Localizer["Page.外圈绑定VSN"].Value),
                this.MakeGridHeader(x => x.InnerAndOutRingRecord_MatchFlag).SetTitle(@Localizer["Page.匹配标识"].Value),
                this.MakeGridHeader(x => x.InnerAndOutRingRecord_CreateTime).SetTitle(@Localizer["_Admin.CreateTime"].Value),
                this.MakeGridHeader(x => x.InnerAndOutRingRecord_UpdateTime).SetTitle(@Localizer["_Admin.UpdateTime"].Value),
                this.MakeGridHeader(x => x.InnerAndOutRingRecord_CreateBy).SetTitle(@Localizer["_Admin.CreateBy"].Value),
                this.MakeGridHeader(x => x.InnerAndOutRingRecord_UpdateBy).SetTitle(@Localizer["_Admin.UpdateBy"].Value),

                this.MakeGridHeaderAction(width: 200)
            };
        }

        
        public override IOrderedQueryable<InnerAndOutRingRecord_View> GetSearchQuery()
        {
            var query = DC.Set<InnerAndOutRingRecord>()
                
                .CheckContain(Searcher.InnerMFCode, x=>x.InnerMFCode)
                .CheckContain(Searcher.InnerVSN, x=>x.InnerVSN)
                .CheckContain(Searcher.OutMFcode, x=>x.OutMFcode)
                .CheckContain(Searcher.OutVSN, x=>x.OutVSN)
                .CheckContain(Searcher.MatchFlag, x=>x.MatchFlag)
                .CheckBetween(Searcher.CreateTime?.GetStartTime(), Searcher.CreateTime?.GetEndTime(), x => x.CreateTime, includeMax: false)
                .CheckBetween(Searcher.UpdateTime?.GetStartTime(), Searcher.UpdateTime?.GetEndTime(), x => x.UpdateTime, includeMax: false)
                .CheckContain(Searcher.CreateBy, x=>x.CreateBy)
                .CheckContain(Searcher.UpdateBy, x=>x.UpdateBy)
                .Select(x => new InnerAndOutRingRecord_View
                {
				    ID = x.ID,
                    
                    InnerAndOutRingRecord_InnerMFCode = x.InnerMFCode,
                    InnerAndOutRingRecord_InnerVSN = x.InnerVSN,
                    InnerAndOutRingRecord_OutMFcode = x.OutMFcode,
                    InnerAndOutRingRecord_OutVSN = x.OutVSN,
                    InnerAndOutRingRecord_MatchFlag = x.MatchFlag,
                    InnerAndOutRingRecord_CreateTime = x.CreateTime,
                    InnerAndOutRingRecord_UpdateTime = x.UpdateTime,
                    InnerAndOutRingRecord_CreateBy = x.CreateBy,
                    InnerAndOutRingRecord_UpdateBy = x.UpdateBy,
                })
                .OrderBy(x => x.ID);
            return query;
        }

        
    }
    public class InnerAndOutRingRecord_View: InnerAndOutRingRecord
    {
        
        public string InnerAndOutRingRecord_InnerMFCode { get; set; }
        public string InnerAndOutRingRecord_InnerVSN { get; set; }
        public string InnerAndOutRingRecord_OutMFcode { get; set; }
        public string InnerAndOutRingRecord_OutVSN { get; set; }
        public string InnerAndOutRingRecord_MatchFlag { get; set; }
        public DateTime? InnerAndOutRingRecord_CreateTime { get; set; }
        public DateTime? InnerAndOutRingRecord_UpdateTime { get; set; }
        public string InnerAndOutRingRecord_CreateBy { get; set; }
        public string InnerAndOutRingRecord_UpdateBy { get; set; }

    }

}